package com.lvt.design.pattern.module.stat.v3;

/**
 * @author LT
 * @date 2023年02月22日 23:17
 */
public class ClientDemo {
    public static void main(String[] args) {
        MetricsStorage storage = new RedisMetricsStorage();
        Aggregator aggregator = new Aggregator();

        ConsoleViewer consoleViewer = new ConsoleViewer();
        ConsoleReporter consoleReporter = new ConsoleReporter(storage, aggregator, consoleViewer);
        consoleReporter.startRepeatedReport(60, 60);

        EmailViewer emailViewer = new EmailViewer();
        EmailReporter emailReporter = new EmailReporter(storage, aggregator, emailViewer);
        emailReporter.startDailyReport();

        MetricsCollector controller = new MetricsCollector(storage);
        controller.recordRequest(new RequestInfo("register", 123, 10234));
        controller.recordRequest(new RequestInfo("register", 123, 11234));
        controller.recordRequest(new RequestInfo("register", 123, 12234));
        controller.recordRequest(new RequestInfo("login", 23, 12234));
        controller.recordRequest(new RequestInfo("login", 1223, 14234));

        try {
            Thread.sleep(100000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
    }
}
